package com.fpx.metadata.controller;

import com.fpx.metadata.bean.po.Impact;
import com.fpx.metadata.service.ImpactService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("impact")
@Api(value="/rjob", tags="影响信息")
public class ImpactController {

    @Autowired
    private ImpactService impactService;

    @ApiOperation(value="分页查询", notes = "分页查询")
    @GetMapping("queryListByPage/v1/{page}/{rows}")
    public PageInfo<Impact> queryListByPage(@PathVariable Integer page, @PathVariable Integer rows) {
        return impactService.queryPageListByWhere(null, page, rows);
    }

    @ApiOperation(value="根据ID查询", notes = "根据ID查询")
    @GetMapping("queryById/{id}")
    public Impact queryById(@PathVariable Long id) {
        return impactService.queryById(id);
    }


    @ApiOperation(value="保存", notes = "保存")
    @PostMapping("save")
    public String save(Impact impact) {
        return impactService.saveSelect(impact) > 0 ? "succese" : "error";
    }

    @ApiOperation(value="更新", notes = "更新")
    @PutMapping("udpate")
    public String update(Impact impact) {
        return impactService.updateSelective(impact) > 0 ? "succese" : "error";
    }

}
